package com.edu.dk.security.impl;

import javax.servlet.ServletException;

import com.edu.dk.security.Filter;
import com.edu.dk.security.WebContext;

/**
 * filter的抽象实现
 * 
 * 
 */
public abstract class AbstractFilter implements Filter {
	protected String filterName;

	@Override
	public void setFilterName(String filterName) {
		this.filterName = filterName;
	}

	@Override
	public String getFilterName() {
		return filterName;
	}

	@Override
	public WebContext wrapContext(WebContext wrappedContext) {
		WebContext context = getAlreadyWrappedContext(wrappedContext);
		initContext(context);
		return context;
	}

	protected void initContext(WebContext context) {

	}

	/**
	 * 
	 * 返回已经包装的上下文
	 * 
	 * @param wrappedContext
	 * @return
	 */
	protected WebContext getAlreadyWrappedContext(WebContext wrappedContext) {
		return new DefaultWebContext(wrappedContext);
	}

}
